<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
  		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<style>
			.layui-body{
				margin-left: -200px;
			}
			.check{
				width: 15px;
				height: 15px;
				border: 1px solid #DADADA;
			}
		</style>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>用户管理</title>
		<link rel="stylesheet" href="/lzproject/CSS/layui.css">
		<link rel="stylesheet" href="/lzproject/CSS/global.css">
		<link rel="stylesheet" href="/lzproject/CSS/red.css">
		<link rel="stylesheet"  href="/lzproject/CSS/layer.css"/>
		
		<script type="text/javascript" src="/lzproject/Js/jquery.min.js"></script>
		<script type="text/javascript" src="/lzproject/Js/Navigation/layui.js"></script>
		<script type="text/javascript" src="/lzproject/Js/icheck.js"></script>
		<script type="text/javascript" src="/lzproject/Js/dw.js"></script>

</head>

	<body class="layui-layout-body">
	<script type="text/javascript">
	$(document).ready(function() {
		select();
	})

	function select() {
		$.ajax({
			//几个参数需要注意一下
			type : "GET",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			data: $('#name_form').serialize(),
			url : "/lzproject/getall/userinfo.do",//url
			success : function(result) {
                var carNewsList = "";
                var data = result.data;
                $.each(data, function(index, element) {
                    carNewsList += "<tr><td><input type=\'checkbox\' name=\'id\' value=\'"+element.user_id+"\'></td><td>"+element.username
                    +"</td><td>"+element.phone_number+"</td><td>"+element.age+"</td><td>";
                    if (element.sex == 0) {
					 carNewsList +="男";
				    } else {
					 carNewsList +="女";
				    }
                    carNewsList +="</td><td>"+element.birth+"</td><td class=\'text-center\'><div class=\'layui-btn-group\'><button class=\'layui-btn layui-btn-xs layui-btn-normal dw-dailog\' dw-url=\'UserInfo.jsp?id=2\' dw-title=\'编辑\'>"
				    +"<img src=\'/lzproject/Img/img-add.png\' />编辑?</button><button class=\'layui-btn layui-btn-xs layui-btn-danger dw-delete\' dw-url=\'delete.html?id=1\' dw-title=\'删除\'>"
					+"<img src=\'/lzproject/Img/img-del.png\' />删除</button></div></td></tr>";
                });
                $("#tbody").html(carNewsList); 
			},
			error : function() {
				alert("异常！");
			}
		});
	}
</script>
		<div class="layui-layout layui-layout-admin">
			<div class="layui-body">
				<div>
					<fieldset class="layui-elem-field">
						<legend>用户管理 - 用户列表</legend>
						<div class="layui-field-box">
							<form class="layui-form" id="name_form">
								<div class="layui-form-item" style="text-align:center;">
									<div class="layui-inline">
										<div class="layui-input-inline">
											<input autocomplete="off" class="layui-input" placeholder="请输入用户名" type="text" name="username" >
										</div>
									</div>
									<div class="layui-inline" style="text-align:left;">
										<div class="layui-input-inline">
										    <input type="button" class="layui-btn" onclick="select()" value="查询">
										</div>
									</div>
								</div>
							</form>
							<hr>
							<div class="layui-btn-group">
								<button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog" dw-url="UserInfo.jsp" dw-width="100%" dw-height="100%">
                      				<img src="/lzproject/Img/img-add.png" />新增
                 		 		</button>
								<button class="layui-btn layui-btn-xs layui-btn-danger dw-batch-delete" dw-url="./delete.json">
                      				<img src="/lzproject/Img/img-del.png" />删除
                  				</button>
								<button class="layui-btn layui-btn-xs dw-refresh">
                      				<img src="/lzproject/Img/img-refresh.png" />刷新
                  				</button>
							</div>
							<hr>
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col width="150">
									<col width="200">
								</colgroup>
								<thead>
									<tr>
										<th class="selectAll"><input type="checkbox" class="check"></th>
										<th>用户名</th>
										<th>联系方式</th>
										<th>年龄</th>
										<th>性别</th>
										<th>生日</th>
										<th style="text-align:center;">操作</th>
									</tr>
								</thead>
								<tbody id="tbody">
									
									
								</tbody>
							</table>
						</div>
					</fieldset>
				</div>
			</div>
		</div>
		
	</body>

</html>
